<!DOCTYPE html>
<html lang="en">
<head>
    <include file="Public:header2" />
    <script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
    <script type="text/javascript" src="__PUBLIC__/Home/js/jquery.cookies.2.2.0.js"></script>
</head>
<style type="text/css">

</style>
<body class="blackbg">
<div id="container" class="logbg">
    <div class="log_title">
        <span class="back"><a href="javascript:history.go(-1)"></a></span>
        {:L('设置交易密码')}
    </div>
    <div class="logbot">
        <form>
            <input type="password" placeholder="{:L('交易密码')}" class="logipt" id="newpaypassword">
            <p style="font-size:14px;line-height:24px;color:#ff8800;padding-left:10px;">
                {:L('警告：交易密码不要与登录密码或者其他网站密码一致，由此产生的账号被盗，本站概不负责。')}
            </p>
            <input type="password" placeholder="{:L('重复密码')}" class="logipt" id="repaypassword">
            <div class="yzmbox">
                <input type="text" placeholder="{:L('验证码')}" class="logipt yzmipt"  id="mobile_verify" >
                <input type="button" value="{:L('获取验证码')}" class="phonebut" id="regBtn"  value="{:L('获取验证码')}" onclick="SendCode()" style="margin-top:15px;background:#ff9900;color:#fff;">
                <p id="repassword-msg" data-explain="{:L('重复输入密码，两次需要一致')}<em></em>" style="font-size:14px;line-height:24px;color:#ff8800;padding-left:10px;">{:L('接收短信的手机')}{$mobile}<em></em></p>
            </div>
            <input type="button" class="logbut" value="{:L('保存')}" onclick="Update()">
        </form>
    </div>
</div>
<script>
    function SendCode() {
        layer.load(0, {shade: [0.5,'#8F8F8F']});
        $('#regBtn').attr("disabled", "disabled");
        $.post("{:U('Verify/paypass')}", {}, function (data) {
            layer.closeAll();
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1
                });
                var obj = $('#regBtn');
                var wait = 120;
                var interval = setInterval(function () {
                    obj.css('backgroundColor', '#999B9C');
                    obj.val(wait + '{:L('秒再次发送')}');
                    wait--;
                    if (wait < 0) {
                        $('#regBtn').removeAttr("disabled");
                        clearInterval(interval);
                        obj.val('{:L('获取验证码')}');
                        obj.css('backgroundColor', '#ff9900');
                    }
                    ;
                }, 1000);
            } else {
                $('#regBtn').removeAttr("disabled");
                layer.msg(data.info, {
                    icon: 2
                });
            }
        }, "json");
    }


    function Update(){
        var repaypassword = $("#repaypassword").val();
        var newpaypassword = $("#newpaypassword").val();
        var oldpaypassword = $("#oldpaypassword").val();
        var mobile_verify = $("#mobile_verify").val();

        if (mobile_verify == "" || mobile_verify == null) {
            layer.tips('{:L('请输入短信验证码')}', '#mobile_verify', {tips: 3});
            return false;
        }

        if (newpaypassword == "" || newpaypassword == null) {
            layer.tips('{:L('请设置6~16位密码，不含特殊符号！')}', '#newpaypassword', {tips: 3});
            return false;
        }

        if (repaypassword == "" || repaypassword == null) {
            layer.tips('{:L('请输入确认新密码')}', '#repaypassword', {tips: 3});
            return false;
        }

        $.post("{:U('mobile/User/uppaypasswordset')}",{mobile_verify : mobile_verify,paypassword : $('#newpaypassword').val(),repaypassword : $('#repaypassword').val() },function(data){
            if(data.status==1){
                layer.msg(data.info,{icon : 1 });
                setTimeout("remainTime()",3000);
            }else{
                layer.msg(data.info,{icon : 2 });
                if(data.url){
                    window.location=data.url;
                }
            }
        },"json");
    }
    function remainTime(){
        window.location = "{:U('User/index')}";
    }
</script>
</body>
</html>